package com.enjoyor.soa.traffic.core.efoms.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.enjoyor.soa.traffic.core.efoms.mapper.IDateMonitorMapper;
import com.enjoyor.soa.traffic.core.efoms.service.IDateMonitorService;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@Service
@Transactional
@SuppressWarnings("rawtypes")
public class DateMonitorService implements IDateMonitorService{

	@Autowired
	private IDateMonitorMapper dateMonitorMapper;
	@Override
	public ResultPojo getDateMonitorChar(String typeCode, String devId) {
		// TODO Auto-generated method stub
		Map<String,Object> map = new HashMap<>();
		map.put("typeCode",typeCode);
		map.put("devId",devId);
		List<Map> listFlag = dateMonitorMapper.getPingHisList(map);
		List<Map> list = new ArrayList<>();
		if(listFlag.size()>0){
			list = dateMonitorMapper.getDateMonitorChar(map);
			for(int i = 0;i<list.size();i++){
				String timeString = this.getTimeString((String) list.get(i).get("CREATETIME"));
				list.get(i).put("CREATETIME", timeString);
			}
		}
			ResultPojo resultPojo = new ResultPojo();
			resultPojo.setResultList(list);
			return resultPojo;
	}

	@Override
	public ResultPojo getDateMonitorReal(String typeCode, String devId) {
		// TODO Auto-generated method stub
		Map<String,Object> map = new HashMap<>();
		map.put("typeCode",typeCode);
		map.put("devId",devId);
		List<Map> listFlag = dateMonitorMapper.getPingHisList(map);
		List<Map> list = new ArrayList<>();
		if(listFlag.size()>0){
		   list = dateMonitorMapper.getDateMonitorReal(map);
		}
		ResultPojo resultPojo = new ResultPojo();
		resultPojo.setResultList(list);
		return resultPojo;
	}
	
	//判断查询集合长度；
	private String getTimeString(String timeString){
		String resultString = timeString+":00";
		return resultString;
	}

}
